<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post" enctype="multipart/form-data" class="form-x" action="/workview/updataSupervice1" >
	
	<div class="student-list" id="student-list" name="student-list">
	
		
	</div>



      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" id="button bg-main icon-check-square-o" onclick="check11()" > 提交</button>
        </div>
      </div>
	  
    </form>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
    $(function() {
        var supervisetno = localStorage.getItem("supervisetno1");
        $.ajax({
            type: "POST",
            url: "/workview/updataSupervice11",
            data: ({
                tno: supervisetno
            }),
            success: function (data) {
                console.log(data);
                if (data.status == 401) {
                    alert("熔断开启，系统异常");
                    window.location.href = "login.html";
                    return;
                }
                if (data.status == 200) {
                    var lists = data.data;
                    console.log(data);
                    for (var i = 0; i < lists.length; i++) {
                        var html = "";
                        html += `<div class="form-group">
								        <div class="label">
								          <label>工号：</label>
								        </div>
								        <div class="field">
								          <input type="text" class="input w50" value="${lists[i].tno}" name="tno" id="tno" readonly="readonly" data-validate="required:请输入工号长度11位" />
								          <span style="margin-left: 10px; color: red;">*</span>
								          <div class="tips"> </div>
								        </div>
								      </div>
								
								      <div class="form-group">
								        <div class="label">
								          <label>请输入密码：</label>
								        </div>
								        <div class="field">
								          <input type="password" class="input w50" value="${lists[i].password}" name="password" id="password" data-validate="required:请输入工号" />
								          <span style="margin-left: 10px; color: red;">*</span>
								          <div class="tips"> </div>
								        </div>
								      </div>
										
										<div class="form-group">
										  <div class="label">
										    <label>再次输入密码：</label>
										  </div>
										  <div class="field">
										    <input type="password" class="input w50" value="${lists[i].password}" name="password1" id="password1" data-validate="required:请输入工号" />
										    <span style="margin-left: 10px; color: red;">*</span>
										    <div class="tips"> </div>
										  </div>
										</div>
								
								      <div class="form-group">
								        <div class="label">
								          <label>添加姓名：</label>
								        </div>
								        <div class="field">
								          <input type="text" class="input w50" value="${lists[i].name}" name="name" id="name" data-validate="required:请输入添加人的姓名" />
								          <span style="margin-left: 10px; color: red;">*</span>
								          <div class="tips"> </div>
								        </div>
								      </div>
									  
									  <div class="form-group">
									    <div class="label">
									      <label>添加职称：</label>
									    </div>
									    <div class="field">
									      <input type="text" class="input w50" value="${lists[i].professional}" name="professional" id="professional" />
									      <div class="tips"> </div>
									    </div>
									  </div>
									  
									  <div class="form-group">
										   
										   <div class="label">
										     <label>添加性别：</label>
										   </div>
										   <div class="field">
										     <input type="text" class="input w50" value="${lists[i].sex}" name="sex" id="sex" />
										     <div class="tips"> </div>
										   </div>
									   </div>
									
								
								      <div class="form-group">
								          <div class="label">
								            <label>个人照片</label>
								          </div>
								          <div class="field">
								            <input type="file" multiple="multiple" class="input w50"  value="${lists[i].phone_url}" multiple="multiple" id="phone_url" name="phone_url"/>
								            <div class="tips"></div>
								          </div>
								      </div>
									  
									  <div class="form-group">
										<div class="label">
										  <label>添加学院：</label>
										</div>
										<div class="field">
										  <input type="text" class="input w50"  value="${lists[i].college_name}"  name="college_name" id="college_name" data-validate="required:请输入添加人的性别" />
										  <span style="margin-left: 10px; color: red;">*</span>
										  <div class="tips"> </div>
										</div>
										
									  </div>
								      
								        <div class="form-group">
										  <div class="label">
										    <label>添加类别 0 管理 1 老师：</label>
										  </div>
										  <div class="field">
										    <input type="text" class="input w50"  value="${lists[i].type}" name="type" id="type" />
										    <span style="margin-left: 10px; color: red;">*</span>
										    <div class="tips"> </div>
										  </div>
								        </div>
								     
									 <div class="form-group">
									   <div class="label">
									     <label>备注：</label>
									   </div>
									   <div class="field">
									     <input type="text" class="input w50" value="${lists[i].remark}" name="remark" id="remark"  />
									     <div class="tips"> </div>
									   </div>
									 </div>
								   `

                        $('.student-list').html(html);
                    }

                    return;
                }
                if (data.status == 500) {
                    alert("添加失败");
                    window.location.href = "tindex.html";
                    return;
                }
                if (data.status == null) {
                    alert("添加异常");
                    window.location.href = "tindex.html";
                    return;
                }
            },
            error: function (XMLHttpRequest, textStatus) {
                if (textStatus === 'timeout') {
                    alert('請求超時');
                    setTimeout(function () {
                        alert('重新请求');
                    }, 2000);
                }
                // window.location.href="login.html";
                alert("系统异常ajax失败");
            }

        })
    })
    function check11() {
        //var sex1= $("input[name='sex']:checked(1)").val();
        var name = document.getElementById("name").value;
        var password1 = document.getElementById("password1").value;
        var password = document.getElementById("password").value;
        var tno = document.getElementById("tno").value;
        var professional = document.getElementById("professional").value;
        var sex = document.getElementById("sex").value;
        var phone_url = document.getElementById("phone_url").files[0];
        var college_name = document.getElementById("college_name").value;
        var type = document.getElementById("type").value;
        var remark = document.getElementById("remark").value;
       // console.log("名字" + name + "密码" + password + "公号" + tno + "职称" + professional + "性别" + sex + "照片" + phone_url + "学院" + college_name + "类型" + type + "备注" + remark);
        // json1=[{name:name,password:password,tno:tno,professional:professional,sex:sex,phone_url:phone_url,college_name:college_name,type:type,remark:remark}]
        // var json2 = JSON.stringify(json1);
        if (name == null || name == "") {
            alert("名字不能为空");
            return;
        }
        if (password1 == null || password1 == "") {
            alert("请再输入密码");
            return;
        }
        if (password == null || password == "") {
            alert("请输入密码");
            return;
        }
        if (password1 != password) {
            alert("两次密码不一样");
            return;
        }
        if (college_name == null || college_name == "") {
            alert("请选择学院");
            return;
        }
        if (type == null || type == "") {
            alert("请选择类型");
            return;
        }
        var formData = new FormData();
        formData.append("name",name);
        formData.append("password",password);
        formData.append("tno",tno);
        formData.append("professional",professional);
        formData.append("sex",sex);
        formData.append("phone_url",phone_url);
        formData.append("college_name",college_name);
        formData.append("type",type);
        formData.append("remark",remark);

        $.ajax({
            type: "POST",
            url: "/workview/updataSupervice1",
            data:formData,
            processData : false,
            contentType : false,
            cache:false,
            async: false,
            success: function (data) {
               // console.log(data);
                if (data.status == 401) {
                    alert("熔断开启，系统异常");
                    window.location.href = "login.html";
                    return;
                }
                if (data.status == 200) {
                    alert("修改成功")
                    window.location.href = "tindex.html";
                    return;
                }
                if (data.status == 500) {
                    alert("修改失败");
                    window.location.href = "tindex.html";
                    return;
                }
                if (data.status == null) {
                    alert("异常");
                    window.location.href = "tindex.html";
                    return;
                }
            },
            error: function (XMLHttpRequest, textStatus) {
                if (textStatus === 'timeout') {
                    alert('請求超時');
                    setTimeout(function () {
                        alert('重新请求');
                    }, 2000);
                }
                window.location.href = "tindex.html";
            }

        });
    }






</script>
</body>
</html>